package com.example.demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.commom.Result;
import com.example.demo.entity.BookWithUser;
import com.example.demo.mapper.BookWithUserMapper;
import com.example.demo.service.BookWithUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 借阅状态
 *
 */
@RestController
@RequestMapping("/bookwithuser")
@Api(tags = "借阅信息", description = " 0328 王晓月")
public class BookWithUserController {
    @Resource
    private BookWithUserService bookWithUserService;

    /**
     * 插入新的借阅状态
     *
     * @param BookWithUser 通过用户预订
     * @return {@link Result }<{@link ? }>
     */
    @PostMapping("/insertNew")
    @ApiOperation(value = "插入新的借阅状态")
    public Result<?> insertNew(@RequestBody BookWithUser BookWithUser) {
        bookWithUserService.insert(BookWithUser);
        return Result.success();
    }

    /**
     * 更新借阅状态
     *
     * @param BookWithUser 通过用户预订
     * @return {@link Result }<{@link ? }>
     */
    @PostMapping
    @ApiOperation(value = "更新借阅状态")
    public Result<?> update(@RequestBody BookWithUser BookWithUser) {
        bookWithUserService.update(BookWithUser);
        return Result.success();
    }


    /**
     * 删除记录
     *
     * @param
     * @return {@link Result }<{@link ? }>
     */
    @PostMapping("/{deleteRecords}")
    @ApiOperation(value = "删除记录")
    public Result<?> deleteRecords(@PathVariable Long deleteRecords) {
        bookWithUserService.deleteById(deleteRecords);
        return Result.success();
    }


}
